package com.learn.ch02ttlqueue.other;

import jakarta.annotation.Resource;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/27
 * @description ch09 other
 */
@RestController
public class Producer {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/other/send")
    public void senMsg() {
        for (int i = 0; i < 4; i++) {
            int finalI = i;
            rabbitTemplate.convertAndSend("exchangeOther",
                    "other",
                    "msg" + i,
                    msg -> {
                        msg.getMessageProperties().setPriority(4 - finalI);
                        return msg;
                    });
        }
    }
}
